<?php
if($row_menu_one['parent_id']==0){
	$view_post = '<div id="product_catalog">';
	$cap1 = $tc->menu(3);
	while($row_cap1 = mysql_fetch_array($cap1)){
		$view_post .= '<a href="'.$row_cap1['url'].'"><h2>'.$row_cap1['name'].'</h2></a>';
		$cap2 = $tc->menu($row_cap1['id']);
		while($row_cap2 = mysql_fetch_array($cap2)){
			$view_post .= '<div class="item"><a href="'.$row_cap2['url'].'"><img src="'.url_catalog_image.$row_cap2['url_hinh'].'" alt="'.$row_cap2['name'].'" /><h3>'.$row_cap2['name'].'</h3></a></div>';
		}
		$view_post .= '<div style="clear:both; height:1px"></div>';
	}
	$view_post .= '<div style="clear:both; height:1px"></div></div>';
}else{
	$view_post = '<div id="product"><h1>'.$row_menu_one['title'].'</h1><h2>'.$row_menu_one['metaDescription'].'</h2>';
	$cap = $tc->menu($row_menu_one['id']);
	if(mysql_num_rows($cap) > 0){
		while($row_cap = mysql_fetch_array($cap)){
			$view_post .= "<a href=\"{$row_cap['url']}\"><h3>{$row_cap['name']}</h3></a>";
			$list_sp = $tc->list_product($row_cap['id']);
			while($row_list_sp = mysql_fetch_array($list_sp)){
				$view_post .= '<div class="item"><a href="'.$row_cap['url'].$row_list_sp['name_rewrite'].'.html"><img src="'.url_product_thumb_image.$row_list_sp['url_hinh'].'" alt="'.$row_list_sp['name'].'" /><h4>'.$row_list_sp['name'].'</h4></a></div>';
			}
			mysql_free_result($list_sp);
		}
	}else{
		$list_sp = $tc->list_product($row_menu_one['id']);
		while($row_list_sp = mysql_fetch_array($list_sp)){
			$view_post .= '<div class="item"><a href="'.$row_menu_one['url'].$row_list_sp['name_rewrite'].'.html"><img src="'.url_product_thumb_image.$row_list_sp['url_hinh'].'" alt="'.$row_list_sp['name'].'" /><h4>'.$row_list_sp['name'].'</h4></a></div>';
		}
		mysql_free_result($list_sp);
	}
	$view_post .= '<div style="clear:both; height:1px"></div></div>';
}